<template>
  <div :id="defaultConfig.DEFAULT_VIEWER_NAME">
    <div class="yt-viewer">
      <slot />
    </div>
  </div>
</template>

<script lang="ts">
export default {
  name: "ISimViewer",
};
</script>

<script setup lang="ts">
import { createViewer, defaultConfig, setToken } from "yt-cesium";
import { onMounted, provide, shallowRef } from "vue";
import { Viewer } from "cesium";

const viewerInstance = shallowRef<Viewer>();

provide(defaultConfig.DEFAULT_VIEWER_NAME, viewerInstance);

setToken();
onMounted(() => {
  viewerInstance.value = createViewer({ leftClick: false });
});
</script>

<style scoped lang="less">
#cesium-box {
  position: relative;
}

.yt-viewer {
  z-index: 10;
  pointer-events: none;
  position: absolute;
  width: 100%;
  height: 100%;

  & > div {
    pointer-events: auto;
  }
}

:global(.yt-viewer > *) {
  pointer-events: auto;
}
</style>
